class Solution {
public:
    bool wordBreak(string s, unordered_set<string> &dict) {
        int len = s.size();
        if(len <= 0){ return false; }
        
        vector<bool> Break (len+1, false);
        Break[0] = true;
        for(int i = 1; i <= len; ++i){
            for(int j = 0; j < i; ++j){
                if(Break[j] && dict.find(s.substr(j, i-j)) != dict.end()){
                // dict.end??  只要有单词能在 dict 中找到，结果就为真
                    Break[i] = true;
                    break;
                }
            }
        }
        return Break[len];  // 返回整个字符串
    }
};